package org.etcsoft.examples.genealogy.figures;

import org.eclipse.draw2d.ColorConstants;
import org.eclipse.draw2d.Label;
import org.eclipse.draw2d.PolygonShape;
import org.eclipse.draw2d.StackLayout;
import org.eclipse.draw2d.geometry.Rectangle;
import org.etcsoft.examples.genealogy.listener.FigureMover;

/**
 * @author korman21@gmail.com
 *
 */
public class MarriageFigure extends PolygonShape {
    public MarriageFigure(int year) {
        Rectangle rect = new Rectangle(0, 0, 50, 50);
        this.setStart(rect.getTop()); // Top-Middle Point
        this.addPoint(rect.getTop());
        this.addPoint(rect.getLeft());
        this.addPoint(rect.getBottom());
        this.addPoint(rect.getRight());
        this.addPoint(rect.getTop());
        this.setEnd(rect.getTop());
        this.setFill(true);
        this.setBackgroundColor(ColorConstants.lightGray);
        this.setPreferredSize(rect.getSize().expand(1, 1));

        this.setLayoutManager(new StackLayout());
        this.add(new Label(Integer.toString(year)));

        new FigureMover(this);
    }
}
